import request from '@/utils/request'
import type { PageDto, PageReqDto, PagesDto } from '../../types'
import type { AvailableOccupationDto, InsurePeriodServeCompanyDto, OccupationRecordDto } from './types'
import type { OccupationQueryTypeCnEnum } from '@/const/enum'


/**
 * 获取长期保派遣单位信息
 * @param params 
 * @returns 
 */
export function getInsurePeriodServeCompanyDetail(id: number): Promise<InsurePeriodServeCompanyDto> {
    return request.get(`/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/queryById/${id}`)
}

/**
 * 更新地址
 * @param data 
 * @returns 
 */
export function updateAddress(data: {
    serveCompanyId: number
    province: string
    city: string
    district: string
    address: string
}): Promise<void> {
    return request.put('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/updateAddress', data)
}

/**
 * 更新长期保派遣单位特别约定
 * @param data 
 * @returns 
 */
export function updateSpecialAppoint(data: {
    id: number
    specialAppoint: string
}): Promise<void> {
    return request.put('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/updateSpecialAppoint', data)
}

/**
 * 系统可用工种查询
 * @param params 
 * @returns 
 */
export function queryAvailableOccupationList(params: {
    periodServeCompanyId: number
}): Promise<AvailableOccupationDto[]> {
    return request.get('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/queryAvailableOccupation', {
        params
    })
}

/**
 * 工种记录
 * @param params 
 * @returns 
 */
export function queryOccupationRecordList(params: {
    periodServeCompanyId?: number
    serveCompanyOrCompanyName?: string
    queryType?: OccupationQueryTypeCnEnum,
    queryMonth?: string
}): Promise<OccupationRecordDto[]> {
    return request.get('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/queryOccupationRecord', {
        params
    })
}

/**
 * 可用工种启用禁用
 * @param params 
 * @returns 
 */
export function updateOccupationEnable(data: {
    id: number
    enable: boolean
}): Promise<void> {
    return request.put('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/updateOccupationEnable', data)
}

/**
 * 长期保派遣单位拉黑
 * @param data 
 * @returns 
 */
export function addBlackList(data: {
    serveCompanyId: number
    reason: string
    isRetainReportCaseUser: number
    fileUrl: string
}): Promise<void> {
    return request.post('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/addBlacklist', data)
}

// 命名规范
// export enum CommonNameEnum {
//     INSURANCE = '保险',
//     INSURANCE_DAILY = '日日保',
//     INSURANCE_PERIOD = '长期保',
//     INSURANCE_GROUP = '团意日保',
//     ELESIGN = '电子签',
//     PAYWAGE = '子弹发薪',
// }
export function getInsurancePeriodDispatchingUnit (params: PageReqDto & {
    serveCompanyOrCompanyName: string
}): Promise<PageDto<InsurePeriodServeCompanyDto[]>> {
    return request.get('/crm-prod-v2/web/pc/crm/insurePeriodServeCompany/queryPageList', {
        params
    })
}
